Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage on GitHub Actions with xvfb #147

Closed
fregante opened this issue Sep 18, 2019 · 11 comments
Closed

Usage on GitHub Actions with xvfb #147

fregante opened this issue Sep 18, 2019 · 11 comments
Labels

Comments

@fregante
Copy link
Contributor

fregante commented Sep 18, 2019

I tried to install/configure xvfb on GitHub actions to use browser-run/tape-run there, but I was not successful.

If anyone finds a solution, please advise. This is the simplest configuration that's only missing xvfb

on: push
jobs:
  run:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/setup-node@v1
    - run: npm install browser-run
    - run: echo 'console.log(9001); window.close()' | browser-run

I wrote all of this and it exits with 0 but browser-run doesn't output anything. The code is not run at all, invalid JS will also result in browser-run exiting successfully.

on: push
jobs:
  run:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/setup-node@v1
    - run: sudo apt-get install xvfb
    - run: export DISPLAY=':99.0'
    - run: Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
    - run: npm install browser-run
    - run: npm install electron # Without this, Electron complains it's not installed correctly
    - run: echo 'console.log(9001); window.close()' | ./node_modules/.bin/browser-run
@fregante fregante changed the title Usage on GitHub Actions Usage on GitHub Actions with xvfb Sep 18, 2019
@bcomnes
Copy link

bcomnes commented Oct 31, 2019

I had to clean up old xvfp processes but this method has been working for me:

https://github.com/little-core-labs/nanochrome/pull/1/files#diff-42c92e55465a3edde413334753e1c2e9R26

Haven't had a chance to play with browser-run yet in actions.

@bcomnes
Copy link

bcomnes commented Oct 31, 2019

fwiw, its an action https://github.com/marketplace/actions/cleanup-xvfb. Let me know how it goes if you try it out.

@fregante
Copy link
Contributor Author

Would it be possible to create an action that wraps xvfb more cleanly instead?

Before

    - run: sudo apt-get install xvfb
    - name: npm install, build, and test
      run: |
        npm i
        xvfb-run --auto-servernum npm test
      env:
        CI: true
    - name: Cleanup xvfb pidx
      uses: bcomnes/cleanup-xvfb@v1

After

    - name: Test with xvfb
      uses: run-with-xvfb
      with:
        run: npm test
      env:
        CI: true

@juliangruber
Copy link
Owner

I recently set up xvfb with the "Before" method and it worked well. But yes that action looks really cool...I guess it would need to install xvfb by spawning an apt-get child process?

@juliangruber
Copy link
Owner

I might give this a shot, but since it's your idea, if you want to, please go first!

@bcomnes
Copy link

bcomnes commented Nov 17, 2019

I’ve been using actions a bit more an the cleanup might not even be needed. Not sure what was happening before. Running in headless ci, you need to set up a frame buffer for chrome to work. Unless that responsibility is pulled into browser run, setting up per run is the way to go.

@juliangruber
Copy link
Owner

I’ve been using actions a bit more an the cleanup might not even be needed

Same for me, this currently works for headless electron: https://github.com/hypergraph-xyz/desktop/blob/master/.github/workflows/test.yml

@fregante
Copy link
Contributor Author

fregante commented Dec 11, 2019

This is working for me:

on:
  - pull_request
  - push

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - run: npm install
    - run: sudo apt-get install xvfb
    - run: xvfb-run --auto-servernum npm test

If anyone publishes an action like I suggested earlier, leave a comment.

@GabrielBB
Copy link

GabrielBB commented Jan 31, 2020

This is working for me:

on:
  - pull_request
  - push

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - run: npm install
    - run: sudo apt-get install xvfb
    - run: xvfb-run --auto-servernum npm test

If anyone publishes an action like I suggested earlier, leave a comment.

I just published an action like you suggested.

To clean the process I used @bcomnes's script. I added an author header to it. Even tho the cleaning is not really necessary in practice, I wanted the action to feel isolated.

Because I saw @juliangruber conditions his workflow based on platform I added that condition inside the action so your workflow ends up cleaner, if you're not using linux then the command will be executed without using xvfb. In this commit to @juliangruber's repo you guys can see the differences (what before was 7 lines, now can be done with 3).

I added the action in the official electron documentation.

Later I'll add a working-directory parameter because right now you can't run commands in sub-directories

@juliangruber
Copy link
Owner

This is fantastic work @GabrielBB!

@paulmueller
Copy link

paulmueller commented Jan 5, 2021

Since I ended up here and I figured others might as well, this is my solution:

jobs:
  build:
    env:
      DISPLAY: :0
  steps:
    - name: Setup xvfb (Linux)
      if: runner.os == 'Linux'
      run: |
        sudo apt-get install -y xvfb libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xinput0 libxcb-xfixes0
        # start xvfb in the background
        sudo /usr/bin/Xvfb $DISPLAY -screen 0 1280x1024x24 &

Example: https://github.com/ZELLMECHANIK-DRESDEN/ShapeOut2/blob/2307c9f403c586937059d5c97e3ebc2d8769ce0d/.github/workflows/check.yml

I used this to test a PyQt5 application.

kriegaex added a commit to kriegaex/aspectj that referenced this issue Mar 24, 2021
We have 84 times this kind of exceptions in 'ajde' tests in our build
logs on GitHub, even though the tests seem to pass:

  HeadlessException: No X11 DISPLAY variable was set,
  but this program performed an operation which requires it.

I found this discussion:
juliangruber/browser-run#147

And then this GitHub Action:
https://github.com/marketplace/actions/gabrielbb-xvfb-action

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
brianmhunt added a commit to knockout/tko that referenced this issue May 30, 2021
brianmhunt added a commit to knockout/tko that referenced this issue Jun 20, 2021
* update tslib dependency in packages/*/package.json

* add Makefile to .editorconfig

* update packages and lerna config

* update base tsconfig target to ES6

* add several Makefile targets and tools/build.mk with sample esbuild config

* rough-out makefiles with peer dependency compilation

* change peer dependencies to newlines that seem to work better with Makefile targets

* Update make targets for proper Makefile cross-package dependencies

* add the commonjs/esm targets

* add tools for the package template

* remove references to config.yaml

* update Makefile for repackaging; pull package version from lerna.json (for now)

* repackage all package.json files

.. removing `scripts`, `standard`, and other unused package.json fields

* remove `standard` from `repackage`

* improve logging and peer dependency checking

* Remove numerous references to rollup

... and the many workarounds that are now replaced by esbuild

* make) update the Makefile `test` targets

and add test_{package}

* update repackage to export "." and "./helpers"

* repackage with dist/index.js as esm import, dist/index.cjs commonjs

* Fix build/peer dependencies building

* Fix karma testing config for esbuild

* Fix top-level Makefile packaging

* Fix utils.jsx imports / dependencies

* make) add esm dependency to testing; add watch target

* change spec imports from ../src to ../dist

... so we don't have a double-import problem

* consolidate the karma config to tools/karma.conf.js

* fix builder missing karma/frameworks

* tools) fix broken ../{pkg}/dist/*.js

* Move packages/build.knockout to builds/knockout

* Move packages/build.reference to builds/reference

* Fix tests hanging b/c packages/builder had none

* set global export for ko; update knockout builds

* Add a stub for commonjs=>iife exports

* Add BUILD_VERSION to the exports

* tools) Update  & simplify our repackaging with lerna

* add builds/* to the workspaces/clean target

also remove unneeded targets

* fix iife/browser build & BUILD_VERSION

* more fixes of BUILD_VERSION

* build/reference) add tests of iife/root imports

* root) add workspaces builds/; add lerna stream comments

* fix ReferenceError with globals

* make/tools) remove peer_dependenicies in lieu of lerna build

* ci) switch to the circleci orb for saucelabs

* Updated config.yml

* ci) add job

* ci) add `make ci` target and Github workflow

* ci) fix make target

* bind) clean up some imports

* ci) remove peer devDependencies from the monorepo that are used for tests

... because lerna seems to order its topology by dependencies and devDependencies as equivalent

* make) change lerna concurrency to a variable

* Merge branch '130-1-package-update' of github.com:knockout/tko into 130-1-package-update

* Revert "ci) remove peer devDependencies from the monorepo that are used for tests"

This reverts commit b2fcedf.

* ci) use concurrency=1 for build/exec

* ci) change devDependencies to dependencies or peerDependencies

... to avoid circular loops in the Lerna topology algorithm

* make) ensure that the node_modules is built

* workflows) switch to node 16

* ci) add sauce env vars

* ci) remove package-lock.json dupe; start to simplify SauceLabs config

* ci) disable startConnect by default

* ci) disable Safari as it always tseems to time out

* ci) disable SauceLabs, enable local testing

... so we're no longer blocked

* ci) disable SL on pull; set test concurrency=1

* ci) try xvfb-run on Github actions

per:

juliangruber/browser-run#147

* ci) install electron / npm

* ci) try GabrielBB/xvfb-action tests

* ci) switch back to SauceLabs w/o recording/screenshots

... also set test concurrency to 1

* ci) disable CI altogether until we DD it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants